<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use DB;

class DbController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    
    public function getList ()
    {
        // 查询表
        // $res = DB::table('users') -> get();
        $res = DB::table('users') ->where('id', '2') ->  first();
        dd($res);

        return view('test.blog', ['users' => $res]);

    }

    public function getUpdate()
    {
        $res = DB::table('users') -> where('id',5) -> update(['name' => 'lalala']);
        dd($res);
    }
    
    public function getInsert()
    {
        $data = ['name' => 'huxinxin'];
        $res = DB::table('users') -> insert($data);
        dd($res);
    }

    public function getDelete($id)
    {
        $res = DB::table('users') -> where('id', $id) -> delete();
        dd($res);
    }

   
}
